<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员仪表板 - XunAI</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.0/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        .sidebar {
            min-height: 100vh;
            background: #2c3e50;
            color: white;
        }
        .sidebar .nav-link {
            color: rgba(255, 255, 255, 0.8);
            padding: 0.75rem 1rem;
            border-left: 3px solid transparent;
        }
        .sidebar .nav-link:hover {
            color: white;
            background: rgba(255, 255, 255, 0.1);
        }
        .sidebar .nav-link.active {
            color: white;
            border-left-color: #3498db;
            background: rgba(255, 255, 255, 0.1);
        }
        .main-content {
            background: #f8f9fa;
            min-height: 100vh;
        }
        .stat-card {
            background: white;
            border-radius: 10px;
            padding: 1.5rem;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s;
        }
        .stat-card:hover {
            transform: translateY(-2px);
        }
        .welcome-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 2rem;
            border-radius: 10px;
            margin-bottom: 2rem;
        }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <!-- 侧边栏 -->
        <div class="col-md-3 col-lg-2 sidebar">
            <div class="text-center py-4">
                <h4>XunAI 管理后台</h4>
            </div>
            <hr>
            <nav class="nav flex-column">
                <a class="nav-link active" href="#">
                    <i class="bi bi-speedometer2 me-2"></i>仪表板
                </a>
                <a class="nav-link" href="#">
                    <i class="bi bi-people me-2"></i>用户管理
                </a>
                <a class="nav-link" href="#">
                    <i class="bi bi-chat-dots me-2"></i>对话管理
                </a>
                <a class="nav-link" href="#">
                    <i class="bi bi-key me-2"></i>API密钥
                </a>
                <a class="nav-link" href="#">
                    <i class="bi bi-graph-up me-2"></i>使用统计
                </a>
                <a class="nav-link" href="#">
                    <i class="bi bi-gear me-2"></i>系统设置
                </a>
            </nav>
        </div>

        <!-- 主内容区 -->
        <div class="col-md-9 col-lg-10 main-content">
            <div class="container-fluid py-4">
                <!-- 欢迎头 -->
                <div class="welcome-header">
                    <div class="row align-items-center">
                        <div class="col">
                            <h1>欢迎回来，<span th:text="${admin.username}">管理员</span>！</h1>
                            <p class="mb-0">今天是 <span th:text="${#dates.format(#dates.createNow(), 'yyyy年MM月dd日')}"></span></p>
                        </div>
                        <div class="col-auto">
                            <a th:href="@{/logout}" class="btn btn-light">
                                <i class="bi bi-box-arrow-right me-1"></i>退出登录
                            </a>
                        </div>
                    </div>
                </div>

                <!-- 统计卡片 -->
                <div class="row g-4 mb-4">
                    <div class="col-md-3">
                        <div class="stat-card">
                            <div class="d-flex align-items-center">
                                <div class="bg-primary p-3 rounded me-3">
                                    <i class="bi bi-people fs-2 text-white"></i>
                                </div>
                                <div>
                                    <h6 class="text-muted mb-1">总用户数</h6>
                                    <h3 class="mb-0">1,234</h3>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="stat-card">
                            <div class="d-flex align-items-center">
                                <div class="bg-success p-3 rounded me-3">
                                    <i class="bi bi-chat-dots fs-2 text-white"></i>
                                </div>
                                <div>
                                    <h6 class="text-muted mb-1">今日对话</h6>
                                    <h3 class="mb-0">567</h3>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="stat-card">
                            <div class="d-flex align-items-center">
                                <div class="bg-warning p-3 rounded me-3">
                                    <i class="bi bi-key fs-2 text-white"></i>
                                </div>
                                <div>
                                    <h6 class="text-muted mb-1">API调用</h6>
                                    <h3 class="mb-0">89,012</h3>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <div class="stat-card">
                            <div class="d-flex align-items-center">
                                <div class="bg-info p-3 rounded me-3">
                                    <i class="bi bi-file-text fs-2 text-white"></i>
                                </div>
                                <div>
                                    <h6 class="text-muted mb-1">上传文件</h6>
                                    <h3 class="mb-0">456</h3>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 快速操作 -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-header bg-white">
                                <h5 class="card-title mb-0">快速操作</h5>
                            </div>
                            <div class="card-body">
                                <div class="row g-3">
                                    <div class="col-md-3">
                                        <div class="text-center p-3 border rounded">
                                            <i class="bi bi-plus-circle fs-1 text-primary mb-2"></i>
                                            <h6>添加用户</h6>
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="text-center p-3 border rounded">
                                            <i class="bi bi-key fs-1 text-success mb-2"></i>
                                            <h6>管理API密钥</h6>
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="text-center p-3 border rounded">
                                            <i class="bi bi-graph-up fs-1 text-warning mb-2"></i>
                                            <h6>查看统计</h6>
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="text-center p-3 border rounded">
                                            <i class="bi bi-gear fs-1 text-info mb-2"></i>
                                            <h6>系统设置</h6>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 最近活动 -->
                <div class="row mt-4">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-header bg-white">
                                <h5 class="card-title mb-0">最近活动</h5>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                        <tr>
                                            <th>时间</th>
                                            <th>用户</th>
                                            <th>操作</th>
                                            <th>详情</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <td>2024-01-15 14:30</td>
                                            <td>user123</td>
                                            <td>新建对话</td>
                                            <td>创建了新的聊天会话</td>
                                        </tr>
                                        <tr>
                                            <td>2024-01-15 14:25</td>
                                            <td>admin</td>
                                            <td>API调用</td>
                                            <td>DeepSeek API调用成功</td>
                                        </tr>
                                        <tr>
                                            <td>2024-01-15 14:20</td>
                                            <td>user456</td>
                                            <td>文件上传</td>
                                            <td>上传了文档文件</td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>